home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / examine.c < prev    next >
C/C++ Source or Header  |  1996-09-13  |  4KB  |  166 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: examine.c,v 1.5 1996/09/13 17:50:06 digulla Exp $
  4.     $Log: examine.c,v $
  5.     Revision 1.5  1996/09/13 17:50:06  digulla
  6.     Use IPTR
  7.  
  8.     Revision 1.4  1996/08/13 13:52:45  digulla
  9.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  10.     Replaced __AROS_LA by __AROS_LHA
  11.  
  12.     Revision 1.3  1996/08/12 14:20:38  digulla
  13.     Added aliases
  14.  
  15.     Revision 1.2  1996/08/01 17:40:50  digulla
  16.     Added standard header for all files
  17.  
  18.     Desc:
  19.     Lang: english
  20. */
  21. #include <exec/memory.h>
  22. #include <clib/exec_protos.h>
  23. #include <dos/filesystem.h>
  24. #include <dos/exall.h>
  25. #include "dos_intern.h"
  26.  
  27. /*****************************************************************************
  28.  
  29.     NAME */
  30.     #include <clib/dos_protos.h>
  31.  
  32.     __AROS_LH2(BOOL, Examine,
  33.  
  34. /*  SYNOPSIS */
  35.     __AROS_LHA(BPTR,                   lock, D1),
  36.     __AROS_LHA(struct FileInfoBlock *, fib,  D2),
  37.  
  38. /*  LOCATION */
  39.     struct DosLibrary *, DOSBase, 17, Dos)
  40.  
  41. /*  FUNCTION
  42.  
  43.     INPUTS
  44.  
  45.     RESULT
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.  
  55.     INTERNALS
  56.  
  57.     HISTORY
  58.     29-10-95    digulla automatically created from
  59.                 dos_lib.fd and clib/dos_protos.h
  60.  
  61. *****************************************************************************/
  62.  
  63. /*****************************************************************************
  64.  
  65.     NAME
  66.     #include <clib/dos_protos.h>
  67.  
  68.     __AROS_LH2(BOOL, ExamineFH,
  69.  
  70.     SYNOPSIS
  71.     __AROS_LHA(BPTR                  , fh, D1),
  72.     __AROS_LHA(struct FileInfoBlock *, fib, D2),
  73.  
  74.     LOCATION
  75.     struct DosLibrary *, DOSBase, 65, Dos)
  76.  
  77.     FUNCTION
  78.  
  79.     INPUTS
  80.  
  81.     RESULT
  82.  
  83.     NOTES
  84.  
  85.     EXAMPLE
  86.  
  87.     BUGS
  88.  
  89.     SEE ALSO
  90.  
  91.     INTERNALS
  92.  
  93.     HISTORY
  94.     29-10-95    digulla automatically created from
  95.                 dos_lib.fd and clib/dos_protos.h
  96.  
  97. *****************************************************************************/
  98. /*AROS alias ExamineFH Examine */
  99. {
  100.     __AROS_FUNC_INIT
  101.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  102.  
  103.     UBYTE buffer[512];
  104.     struct ExAllData *ead=(struct ExAllData *)buffer;
  105.     STRPTR src, dst;
  106.     ULONG i;
  107.  
  108.     /* Get pointer to filehandle */
  109.     struct FileHandle *fh=(struct FileHandle *)BADDR(lock);
  110.  
  111.     /* Get pointer to process structure */
  112.     struct Process *me=(struct Process *)FindTask(NULL);
  113.  
  114.     /* Get pointer to I/O request. Use stackspace for now. */
  115.     struct IOFileSys io,*iofs=&io;
  116.  
  117.     /* Prepare I/O request. */
  118.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  119.     iofs->IOFS.io_Message.mn_ReplyPort     =&me->pr_MsgPort;
  120.     iofs->IOFS.io_Message.mn_Length     =sizeof(struct IOFileSys);
  121.     iofs->IOFS.io_Device =fh->fh_Device;
  122.     iofs->IOFS.io_Unit     =fh->fh_Unit;
  123.     iofs->IOFS.io_Command=FSA_EXAMINE;
  124.     iofs->IOFS.io_Flags  =0;
  125.     iofs->io_Args[0]=(IPTR)buffer;
  126.     iofs->io_Args[1]=512;
  127.     iofs->io_Args[2]=ED_OWNER;
  128.  
  129.     /* Send the request. */
  130.     DoIO(&iofs->IOFS);
  131.  
  132.     /* Set error code and return */
  133.     if((me->pr_Result2=iofs->io_DosError))
  134.     return 0;
  135.     else
  136.     {
  137.     fib->fib_DiskKey=0;
  138.     fib->fib_DirEntryType=ead->ed_Type;
  139.     src=ead->ed_Name;
  140.     dst=fib->fib_FileName;
  141.     if(src!=NULL)
  142.         for(i=0;i<107;i++)
  143.         if(!(*dst++=*src++))
  144.             break;
  145.     *dst++=0;
  146.     fib->fib_Protection=ead->ed_Prot^0xf;
  147.     fib->fib_EntryType=ead->ed_Type;
  148.     fib->fib_Size=ead->ed_Size;
  149.     fib->fib_Date.ds_Days=ead->ed_Days;
  150.     fib->fib_Date.ds_Minute=ead->ed_Mins;
  151.     fib->fib_Date.ds_Tick=ead->ed_Ticks;
  152.     src=ead->ed_Comment;
  153.     dst=fib->fib_Comment;
  154.     if(src!=NULL)
  155.         for(i=0;i<79;i++)
  156.         if(!(*dst++=*src++))
  157.             break;
  158.     *dst++=0;
  159.     fib->fib_OwnerUID=ead->ed_OwnerUID;
  160.     fib->fib_OwnerGID=ead->ed_OwnerGID;
  161.     return 1;
  162.     }
  163.  
  164.     __AROS_FUNC_EXIT
  165. } /* Examine */
  166.